< previous page page_444 next page >

Page 444
Listing 11.29. continued
            objDG.DatabaseName = Data1.DatabaseName
            objDG.SQLSelect = strSQL
            objDG.GraphType = dgPie3d
            objDG.GraphField = "SalesTotal"
            objDG.GraphTitle = "Sales by Region"
            objDG.LegendField = "Region"
            '
        Case 1 ' sales by month
        Case 2 ' sales by customer
End Select
    '
    objDG.ShowGraph
    '
End Sub
Notice that you used the SQL statement you defined earlier as the SQLSelect property of the DataGraph object. The rest of the code should be familiar by now: You set several properties that are required for the graph object library and then you called the ShowGraph method.
Note.gif
It is important to keep in mind that you did not have to load the GRAPH32.OCX file into your project. Because this is part of the ActiveX DLL, you do not need to identify it in the Visual Basic project that uses the DLL. The OCX, and its supporting files, must be present on your machine, but you do not have to add it to your project.

Now, save and run the project. When you select Graph | Sales by Region from the main menu, you should see a graph like the one shown in Figure 11.14.
0444-01.jpg
Figure 11.14.
Displaying the Sales by Region pie graph.

 
< previous page page_444 next page >

If you like this book, buy it!